import BaseUtil from '@/BaseUtil';
import SelectUtil from '@/SelectUtil';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 狗头人 - 死亡报复
 **/
export default class MSK_DogManDie extends AbilityBase {
    static instance: MSK_DogManDie;
    constructor(id: string = 'Mgt2') {
        super(id);
        MSK_DogManDie.instance = this;
        this.init();
        EventManager.单位死亡(this.onSpellEffect.bind(this));
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        DestroyEffect(AddSpecialEffect('Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl', tarX, tarY));
        let es = SelectUtil.getEnemyUnitsInRange(source, 250);
        DamageSystemInstance.applyAoeMagicDamage(es, source, 250, 'fire');
        handle_unref(source);
    }
    onSpellEffect(d: DamageEventData) {
        if (GetUnitAbilityLevel(d.target, this.id) == 0) return;
        let x = GetUnitX(d.target),
            y = GetUnitY(d.target);
        handle_ref(d.target);
        BaseUtil.runLater(1, () => {
            this.cast(x, y, d.target, d.target, d);
        });
    }
}
